{extend name="layout:base" /}
{block name="page_content"}
  <div class="row">
    <div class="col-xs-12">
      <div class="tabbable">
        <ul class="nav nav-tabs" id="myTab">
          {volist name="$parents" id="item"}
            <li <?php if($item['id'] == $parent_id){ echo('class="active"'); } ?>>
              <a href="{:url('index', ['parent_id' => $item['id']])}">
                {$item.title}
              </a>
            </li>
          {/volist}
        </ul>
        <div class="tab-content">
          <div class="row maintop">
            <div class="col-xs-12">
              <form name="form_search" class="form-search form-inline" method="get" action="{:url('index')}">
                <?php if($parent_id > 0 && $auth->check('create')): ?>
                  <div class="form-group">
                    <a href="{:url('create', ['parent_id' => $parent_id])}" class="btn btn-sm btn-primary mr-10">
                      <i class="ace-icon fa fa-plus bigger-110"></i>
                      添加
                    </a>
                  </div>
                <?php endif; ?>
              </form>
            </div>
          </div>

          <form method="post" action="{:url('resort', ['parent_id' => $parent_id])}" >
            <table class="table table-striped table-bordered table-hover" id="dynamic-table">
              <thead>
                <tr>
                  <th class="field-style">排序编号</th>
                  <th>ID</th>
                  <th>分类名</th>
                  <th class="center">更新用户</th>
                  <th class="center">更新时间</th>
                  <th class="center">操作</th>
                </tr>
              </thead>
              <tbody>
                {volist name="$list" id="vo"}
                  <tr>
                    <td class="field-style center">
                      <input type="text" maxlength="4" name="items[{$vo.id}]" value="{$vo.sort}" class="field-style">
                    </td>
                    <td>
                      {$vo.id}
                    </td>
                    <td>
                      {$vo.title}
                    </td>
                    <td>
                      {$vo.member_name}
                    </td>
                    <td class="center">
                      {$vo.update_time}
                    </td>
                    <td class="center">
                      <?php if($auth->check('update')): ?>
                        <a class="green" href="{:url('update', ['id' => $vo['id'], 'parent_id' => $vo['parent_id']])}">
                          <i class="ace-icon fa fa-pencil bigger-130"></i>编辑
                        </a>
                      <?php endif; ?>
                      <?php if($auth->check('delete')): ?>
                        <a class="red" href='javascript:void(0)' onclick="alert_del('{:url("delete", ["id" => $vo["id"], "parent_id" => $vo["parent_id"]])}', '确认要删除吗？');" class="tooltip-error" data-rel="tooltip" title="删除">
                          <i class="ace-icon fa fa-trash-o bigger-130"></i>删除
                        </a>
                      <?php endif; ?>
                    </td>
                  </tr>
                {/volist}
              </tbody>
            </table>
            <div class="row">
              <div class="col-xs-12">
                <?php if($auth->check('resort')): ?>
                  <button class="btn btn-xs btn-info btn-resort" type="submit">
                    更新排序
                  </button>
                <?php endif; ?>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
{/block}